/***************************************************************************
 *   Copyright (C) 2008 by Thomas Fannes                                   *
 *   thomasfannes@gmail.com                                                *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
 ***************************************************************************/
#ifndef STRUCTUREBOARD_H
#define STRUCTUREBOARD_H

#include <QVector>
#include <QString>
#include "Tile.h"
#include "Player.h"
#include "CornerBuilding.h"
#include "SideBuilding.h"
#include "BoardDescription.h"
#include "HexGrid.h"

namespace board
{
	class Player;
	class Tile;
	class CornerBuilding;
	class SideBuilding;

	class Board
	{
		public:
			// constructors & deconstructor
			Board();
			Board ( const BoardDescription & description );
			~Board();

			// description functions
			BoardDescription getDescription() const;

			// creation functions
			Tile * setTile(const structure::HexVector & position, TileData data);
			SideBuilding * setSideBuilding(const structure::HexVector & position, SideBuildingData data, Player * player = 0);
			CornerBuilding * setCornerBuilding(const structure::HexVector & position, CornerBuildingData data, Player * player = 0);
			Player * setPlayer(unsigned int playerID, const QString & name);

			void removeTile(const structure::HexVector & position);
			void removeSideBuilding(const structure::HexVector & position);
			void removeCornerBuilding(const structure::HexVector & position);

			Tile * getTileAt(const structure::HexVector & position) const;
			SideBuilding * getSideBuildingAt(const structure::HexVector & position) const;
			CornerBuilding * getCornerBuildingAt(const structure::HexVector & position) const;

			// information functions
			const QVector<Tile *> & getTiles() const {return arTiles; };
			const QVector<CornerBuilding *> & getCornerBuildings() const  {return arCornerBuildings; };
			const QVector<SideBuilding *> & getSideBuildings() const { return arSideBuildings; };
			const QVector<Player *> & getPlayers() const { return arPlayers; };



		private:
			// helper functions
			void clean();

		private:
			structure::HexGrid grid;
			QVector<Tile *> arTiles;
			QVector<CornerBuilding *> arCornerBuildings;
			QVector<SideBuilding *> arSideBuildings;
			QVector<Player *> arPlayers;
	};

}

#endif
